/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.route.system.bean;

import com.route.system.entity.RpsStation;
import com.route.system.session.RpsStationFacade;
import java.io.Serializable;
import java.util.List;
import java.util.Locale;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author neco
 */
@ManagedBean(name = "StationBean")
@ViewScoped
public class StationBean implements Serializable {

    private RpsStation startStation = new RpsStation();
    private RpsStation endStation = new RpsStation();
    @EJB
    private RpsStationFacade rpsStationFacade;

    public StationBean() {
    }

    public List<RpsStation> completeStartStationByName(String stationName) {
        if ((endStation != null) && (endStation.getStationId() != null)) {
            return rpsStationFacade.completeByNameAndWithOutStationId("%" + stationName.toUpperCase(new Locale("tr", "TR")) + "%", endStation.getStationId());
        } else {
            return rpsStationFacade.completeByName("%" + stationName.toUpperCase(new Locale("tr", "TR")) + "%");
        }
    }

    public List<RpsStation> completeEndStationByName(String stationName) {
        if ((startStation != null) && (startStation.getStationId() != null)) {
            return rpsStationFacade.completeByNameAndWithOutStationId("%" + stationName.toUpperCase(new Locale("tr", "TR")) + "%", startStation.getStationId());
        } else {
            return rpsStationFacade.completeByName("%" + stationName.toUpperCase(new Locale("tr", "TR")) + "%");
        }
    }

    public RpsStation getEndStation() {
        return endStation;
    }

    public void setEndStation(RpsStation endStation) {
        this.endStation = endStation;
    }

    public RpsStation getStartStation() {
        return startStation;
    }

    public void setStartStation(RpsStation startStation) {
        this.startStation = startStation;
    }
}
